<template>
    <view class="news-list">
        <scroll-view :scroll-top="-10" :scroll-y="true" class="scroll-Y" @scrolltoupper="upper" @scrolltolower="lower"
            @scroll="scroll" :enable-back-to-top="true">
            <view class="mar-hov-mm">
                <news-cell class="" :newsList="newsList" :type="newsType"></news-cell>
                <uni-load-more :status="loadMoreStatus"></uni-load-more>
            </view>
        </scroll-view>
    </view>
</template>

<script>
    import newsCell from '../../components/newsCell.vue';
    import uniLoadMore from "@dcloudio/uni-ui/lib/uni-load-more/uni-load-more.vue";
    export default {
        components: {
            newsCell,
            uniLoadMore
        },
        onLoad(o) {
        	console.log(o);
            if (o && o.type) {
                this.newsType = o.type;
                uni.request({
                	url: '获取',
                	method: 'GET',
                	data: {
                        type: o.type
                    },
                	success: res => {},
                	fail: () => {},
                	complete: () => {}
                });
            }
        },
        data() {
            return {
                newsType: 1,
                newsList: [{
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    },
                    {
                        title: "助学贷款还没还完 培训机构却跑路了 ",
                        date: "2019-03-04 10:45:22",
                        imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                    }

                ],
                loadMoreStatus: "more"
            }
        },
        methods: {
            upper(e) {},
            lower(e) {
                this.loadMoreStatus = "loading";
                setTimeout(() => {
                    this.loadMoreStatus = "noMore";
                }, 2000);
                uni.request({
                    url: 'https://www.example.com/request', //仅为示例，并非真实接口地址。
                    data: {
                        text: 'uni.request'
                    },
                    header: {
                        'custom-header': 'hello' //自定义请求头信息
                    },
                    success: (res) => {
                        res = {
                            resList: [{
                                    title: "助学贷款还没还完 培训机构却跑路了 ",
                                    date: "2019-03-04 10:45:22",
                                    imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                                },
                                {
                                    title: "助学贷款还没还完 培训机构却跑路了 ",
                                    date: "2019-03-04 10:45:22",
                                    imgUrl: "http://img.900sui.com/2019/03/04/5c7c913c06c94.jpg"
                                }
                            ]
                        }
                        if (!res.resList || res.resList.length === 0) {
                            this.loadMoreStatus = "noMore";
                        } else {
                            this.loadMoreStatus = "more";
                        }
                        this.newsList = this.newsList.concat(res.resList);
                    },
                    fail: (err) => {

                    },
                    complete: (res) => {

                    }
                });
            },
            scroll(e) {}
        }
    }
</script>

<style>
    .news-list {
        background-color: #f3f4f5;
    }

    .scroll-Y {
        min-height: calc(100vh - 44px);
        /* #ifdef MP-WEIXIN || APP-PLUS */
        min-height: calc(100vh);
        /* #endif */
        height: 50vh;
    }
</style>
